package structuralPattern.bridge;

/**
 * 实现化角色
 */
interface Implementor {
    void operationImpl();
}

/**
 * @Author: Alex Hu
 * Date: 2020/2/22 3:06 下午
 * Content:
 */
public class BridgeTest {
    public static void main(String[] args) {
        Implementor impl = new ConcreteImplementorA();
        Abstraction abs = new RefinedAbstraction(impl);
        abs.operation();
    }
}

/**
 * 具体实现化角色
 */
class ConcreteImplementorA implements Implementor {
    @Override
    public void operationImpl() {
        System.out.println("具体实现化(Concrete Implementor)角色被访问");
    }
}

/**
 * 抽象化角色
 */
abstract class Abstraction {
    protected Implementor impl;

    protected Abstraction(Implementor impl) {
        this.impl = impl;
    }

    public abstract void operation();
}

/**
 * 扩展抽象化角色
 */
class RefinedAbstraction extends Abstraction {
    protected RefinedAbstraction(Implementor imple) {
        super(imple);
    }

    @Override
    public void operation() {
        System.out.println("扩展抽象化(Refined Abstraction)角色被访问");
        impl.operationImpl();
    }
}
